home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / program / ddj0897.zip / RCSC.ZIP / LIB51 / OTOI.C < prev    next >
Text File  |  1997-01-12  |  365b  |  17 lines

  1. /*
  2. ** otoi -- convert unsigned octal string to integer nbr
  3. **          returns field size, else ERR on error
  4. */
  5. otoi(octstr, nbr)  char *octstr;  int *nbr;  {
  6.   int d,t; d=0;
  7.   *nbr=0;
  8.   while((*octstr>='0')&(*octstr<='7')) {
  9.     t=*nbr;
  10.     t=(t<<3) + (*octstr++ - '0');
  11.     if ((t>=0)&(*nbr<0)) return ERR;
  12.     d++; *nbr=t;
  13.     }
  14.   return d;
  15.   }
  16.  
  17.